home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9772 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: news.uni-stuttgart.de!schweikh
  2. From: schweikh@itosun.ito.uni-stuttgart.de (Jens Schweikhardt)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Segmentation Fault ???
  5. Date: 13 Mar 1996 09:37:20 GMT
  6. Organization: Comp.Center (RUS), U of Stuttgart, FRG
  7. Message-ID: <4i650g$oc8@info4.rus.uni-stuttgart.de>
  8. References: <4hsa7i$en3@wraith.its.uow.edu.au> <4huis1$cm2@ccshst05.cs.uoguelph.ca> <4hv75jINNpss@keats.ugrad.cs.ubc.ca> <4hvaq3$n8f@ccshst05.cs.uoguelph.ca>
  9. NNTP-Posting-Host: itosun.ito.uni-stuttgart.de
  10.  
  11. In article <4hvaq3$n8f@ccshst05.cs.uoguelph.ca>,
  12. Toby K Hay <thay@uoguelph.ca> wrote:
  13.  
  14. [snip]
  15.  
  16. >From three replies I received via E-mail I understand that accessing 
  17. >illegal memory is almost certainly caused by using uninitialized pointers 
  18. >- something I will check my code for again.  But what determines the 
  19. >limits of my malloc heap, stack, and so forth?  Can I request more memory 
  20. >for these at the command line when I start the program?
  21.  
  22. The limits in UNIX are determined by the available virtual memory.
  23. You can not request more resources per program. You also don't have
  24. to specify it at link time (how many stack space etc, like you
  25. may have to on DOS systems) or whenever.
  26. The address space of your program grows dynamically. Malloc
  27. will probably call sbrk() on UNIX to increase the heap.
  28. It will return NULL if the request can't be satisfied.
  29. So be sure to always *test* what malloc returns.
  30.  
  31. As for the stack space, it'll also grow as needed,
  32. as long as there is virtual memory available. In case
  33. it's used up your program is likely to get a lethal signal.
  34. But unless your program is really pathological I bet
  35. you never see this happen. It didn't occur to me in 10 years
  36. of UNIX programming.
  37.  
  38.  
  39. There is however a limit on certain resources in UNIX,
  40. like maximum address space and file size. The SVR4 csh
  41. for example says
  42. schweikh@itosun:~/ftp> csh -c limit
  43. cputime         unlimited
  44. filesize        unlimited
  45. datasize        2097148 kbytes
  46. stacksize       8192 kbytes
  47. coredumpsize    unlimited
  48. descriptors     64 
  49. memorysize      unlimited
  50.  
  51. Try 'apropos limit' to see how you may list and alter your
  52. resource limits. Note that all this is UNIX specific and
  53. should have been asked in a newsgroup dedicated to UNIX.
  54.  
  55. Bye, Jens
  56.  
  57. -- 
  58. SIGSIG -- signature too long (core dumped)
  59.